﻿using ConfExpert.Entities;
using ConfExpert.Forms.Base;

using DevTeamIT;
using System;
using System.Data;
using System.Windows.Forms;

namespace ConfExpert.Forms.Araclar
{
    public partial class Screenshots : XForm
    {
        public Screenshots()
        {
            InitializeComponent();

            DataSet dsx = new DataSet();            
            DataTable dt = Session.DataManager.ExecuteDataTable("GetScreenshots");
            dsx.Tables.Add(dt);

            BindingSource bs = new BindingSource(dt.DataSet, dt.TableName);
            InitGridView(gridView1, bs);

            gridView1.DoubleClick += new EventHandler(gridView1_DoubleClick);

            gridView1.OptionsBehavior.ReadOnly = true;
            gridView1.OptionsBehavior.Editable = false;
            gridView1.OptionsSelection.MultiSelectMode = DevExpress.XtraGrid.Views.Grid.GridMultiSelectMode.RowSelect;
            gridView1.OptionsSelection.EnableAppearanceFocusedCell = false;

            gridView1.Columns["ScreenShootId"].Visible = false;
            gridView1.Columns["Tarih"].DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
            gridView1.Columns["Tarih"].DisplayFormat.FormatString = "dd/MM/yyyy HH:mm:ss";
            gridView1.BestFitColumns();
            txtInfo.Caption = "Ekran Görüntüleri";
        }

        void gridView1_DoubleClick(object sender, EventArgs e)
        {
            if (gridView1.FocusedRowHandle > -1)
            {
                string Id = gridView1.GetFocusedRowCellValue("ScreenShootId").ToString().Replace("ScreenshotId:", string.Empty);
                using (ImageViewer v = new ImageViewer("select top 1 * from ScreenShoot where ScreenShootId = " + Id))
                    v.ShowDialog();
            }
        }
    }
}